<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <link rel="stylesheet" href="../css/pagination.css">
        <link rel="stylesheet" href="../css/cssreset.css">
        
        <link rel="stylesheet" href="../css/style2.css">
	
		<script src="../js/jquery-1.11.1.min.js"></script>
		<script language="javascript" src="<%=basePath %>js/PCASClass.js"></script>
        
        <style>

 .formdan label.error{
       font-size:13px; 
		margin-left:8px;
		color: orangered;
        }
</style>
        
    </head>
    <body>
    	<div class="bigbox2">
    		<nav class="nav2">
    			<span class="scolor"></span>
    			<ul>
    				<li><a href="../page/originalIndex.jsp"><p class="mline"><span class="smallicon"></span><span class="navtxt">首 页</span></p></a></li>
    				<li><a href="../client/findByIndex.action" id="sline"><p class="mline"><span class="smallicon one1" id="current21"></span><span class="navtxt" id="current2">客 户</span></p></a></li>
    				<li><a href="../sale/findSale.action"><p class="mline"><span class="smallicon one2"></span><span class="navtxt">销 售 机 会</span></p></a></li>
    				<li><a href="../contact/page.action"><p class="mline"><span class="smallicon one3"></span><span class="navtxt">联 系 人</span></p></a></li>
    				<li><a href="../contract/findByAlls.action"><p class="mline"><span class="smallicon one4"></span><span class="navtxt">合 同</span></p></a></li>
    				<li class="shenpi"><a href="../page/pacts.jsp"><p class="mline"><span class="smallicon one8"></span><span class="navtxt">合 同 审 批</span></p></a></li>
    				<c:if test="${sessionScope.backstage == 1}">
   						<li><a href="../staff/selectTree.action"><p class="mline"><span class="smallicon one5"></span><span class="navtxt">后 台 管 理</span></p></a></li>
    				</c:if>
    			</ul>
    		</nav>
    		<div class="showbox3">
	    		<p class="xtitle">客 户 详 情</p>
	    		<span class="boxone">
	    		<div class="above">
	    			<img src="../images/kehu (1).png" alt="" class="po"> 
		    		<span class="salename">
		    		&nbsp;${newClientUtil.client.client_name}

		    		</span>
		    		<span class="open">
		    			<span class="opennew">编 辑</span>
		    		</span>
	    		</div>
		    	<ul class="sun sun2">
		    		<li>
		    			<span class="sone">客户类型</span><br>
		    			<span class="stwo">默认业务类型</span>
		    		</li>
		    		<li>
		    			<span class="sone">公司网址</span><br>
		    			<span class="stwo">${newClientUtil.information.information_website}</span>
		    		</li>
		    		<li>
		    			<span class="sone">电话</span><br>
		    			<span class="stwo">${newClientUtil.information.information_phone}</span>
		    		</li>
		    		<li>
		    			<span class="sone">所属公海</span><br>
		    			<span class="stwo"></span>
		    		</li>
		    		<li>
		    			<span class="sone">客户所有人</span><br>
		    			<span class="stwo">${newClientUtil.staff}</span>
		    		</li>
		    		
		    	</ul>		
	    		</span> 
	    		<div class="b-box"></div>	   		
    		</div>
    		<div class="showbox3 showbox4">
	    		  <div class="boxtwo" style="width:1100px;">
    		<div class="showbox3 showbox4">
	    		  	<div class="boxthree" style="width:99%">
					<span class="threenav"> <a class="fg"
						style="font-size: 20px;" id="dongtai">动态</a> 
						<a href="../client/findByClientId.action?id=${newClientUtil.client.client_id}" style="font-size: 20px;" id="ziliao">资料</a>
					</span>
	    		  		<div class="formdan" id="jiluleixing">
						<form
							method="post" id="salestrack">

							<input type="hidden" id="clientId" value="${client.client_id}" />
							<input type="hidden" id="staffId" value="${client.staffID}" />
							<p style="color: #8fa1b2;padding-left: 1px;margin-top: 20px;">记录类型</p>
							<select id="onessss" class="shenfenselect shenfenselect3"
								style="margin-left: 1px" name="recordId">
								<c:forEach var="records" items="${records}">
									<option value="${records.recordId}">${records.recordName}</option>
								</c:forEach>

								<!--<p style="color: #8fa1b2;padding-left: 1px;padding-bottom: 0px;">客户反馈</p>-->
								<textarea class="fankui" id="fankui" name="saletrackFeedback"
									placeholder="请输入客户反馈信息"
									style="border: 1px solid #cfdae5;height: 80px;padding:5px 5px 5px 10px;color: #8fa1b2;"></textarea>

								<!--<p style="color: #8fa1b2;padding-left: 1px;padding-bottom: 0px;">重要情况说明</p>-->
								<textarea class="fankui1" id="shuoming"
									name="saletrackStatusstatement" placeholder="请输入重要情况说明"
									style="border: 1px solid #cfdae5;height: 80px;padding:5px 5px 5px 10px;color: #8fa1b2;"></textarea>
								<!--<p style="color: #8fa1b2;padding-left: 1px;padding-bottom: 0px;">情况跟踪描述</p>-->
								<textarea class="fankui2" id="miaosu" name="saletrackDescrip"
									placeholder="请输入情况跟踪描述"
									style="border: 1px solid #cfdae5;height: 80px;padding:5px 5px 5px 10px;color: #8fa1b2;"></textarea>
								<p class="ee" style="margin-top: 20px;">
									<button type="submit" class="sm" 
										style="width: 70px;margin-right: 15px;">发表</button>
								</p>
						</form>

						<div class="qingkong">
							<c:forEach items="${saletrack}" var="list">
								<div class="shijian"
									style="width: 100%;height: 30px;line-height: 32px;color:#8fa1b2;padding: 0px 14px;">
									<fmt:formatDate value='${list.saleTrack.saletrackDate}'
										pattern='yyyy-MM-dd' />
								</div>
								<ul class="liuyan"
									style="padding-top: 0px;margin-top: 0px;padding-bottom: 10px;">
									<!--<li class="liuyanp">
	    		  					<span class="smallpic"><img src="${pageContext.request.contextPath}/salejihui/images/icon (29).png" alt="" class="smallpic2">李欢<span style="color:#adadae;margin-left:15px">电话联系了销售机会</span></span>
	    		  					<span class="deleting">删 除<br></span>
	    		  				</li>-->
									<li class="liuyanp" style="background: none;margin-top: 0px;">
										<span class="smallpic" style="margin-top: 20px;"><img
											src="${pageContext.request.contextPath}/salejihui/images/icon (29).png" alt="" class="smallpic2">${list.staff}<span
											style="color:#adadae;margin-left:15px">${list.record}联系了${list.client}客户</span></span> <span
										class="deleting"
										style="margin-top: 10px;float: right;margin-right: 10px;"
										onclick="del(${list.saleTrack.saletrackId})">删 除<br></span><br>
										<span class="liutxt">事件类型:${list.record}</span><br> <span
										class="liutxt">客户反馈:${list.saleTrack.saletrackFeedback}</span><br>
										<span class="liutxt">重要情况说明:${list.saleTrack.saletrackStatusstatement}</span><br>
										<span class="liutxt">情况跟踪描述:${list.saleTrack.saletrackDescrip}</span><br>
									</li>
								</ul>
							</c:forEach>
						</div>

						<!-- <p class="ee"> <input type="submit" value="回复" class="sm"></p> -->
						<!--<p><img src="${pageContext.request.contextPath}/salejihui/images/icon (28).png" alt="" class="shui">2017-07-20 15:02 <span style="color:#1fd4fb;">李欢</span> 将销售机会：<span style="color:#1fd4fb;">财务软件 </span>销售阶段 变为需求确定</p>
	    		  			<p><img src="${pageContext.request.contextPath}/salejihui/images/icon (28).png" alt="" class="shui">2017-07-20 15:02 <span style="color:#1fd4fb;">李欢</span> 将销售机会：<span style="color:#1fd4fb;">财务软件 </span>销售阶段 变为需求确定</p>
	    		  			<p><img src="${pageContext.request.contextPath}/salejihui/images/icon (28).png" alt="" class="shui">2017-07-20 15:02 <span style="color:#1fd4fb;">李欢</span> 将销售机会：<span style="color:#1fd4fb;">财务软件 </span>销售阶段 变为需求确定</p>
	    		  			<p><img src="${pageContext.request.contextPath}/salejihui/images/icon (28).png" alt="" class="shui">2017-07-20 15:02 <span style="color:#1fd4fb;">李欢</span> 将销售机会：<span style="color:#1fd4fb;">财务软件 </span>销售阶段 变为需求确定</p>
	    		  			<p><img src="${pageContext.request.contextPath}/salejihui/images/icon (28).png" alt="" class="shui">2017-07-20 15:02 <span style="color:#1fd4fb;">李欢</span> 将销售机会：<span style="color:#1fd4fb;">财务软件 </span>销售阶段 变为需求确定</p>
	    		  			<p><img src="${pageContext.request.contextPath}/salejihui/images/icon (28).png" alt="" class="shui">2017-07-20 15:02 <span style="color:#1fd4fb;">李欢</span> 将销售机会：<span style="color:#1fd4fb;">财务软件 </span>销售阶段 变为需求确定</p>-->
					</div>
					<div class="M-box" style="margin-left:35%;margin-top:20px;"></div>
	    		  		
	    		  		

	    		  	</div>
	    		  		
    		</div>
    		</div>
    		</div>
    	</div>
    	<div id="cover">
			    		<div id="cover-bg"></div>
						<div id="cover-content">
								<h4>编 辑 客 户<span class="close"></span></h4>
								<p class="main">
									<span class="leftmain">客 户 名 称</span>
									<input type="text" id="client_name" value="${newClientUtil.client.client_name}" placeholder="&nbsp;&nbsp;请输入客户的姓名 " class="shurukuang shurukuang2 shurukuang22">
								</p>
								<p class="main">
									<span class="leftmain" >省 份&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
									<select id="sheng" name="province3" class="shenfenselect shenfenselect4">
							        </select>
							        <select id="shi" name="city3" class="shenfenselect shenfenselect2 shenfenselect4">
							        </select>
							        <select id="xiang" name="area3" class="shenfenselect shenfenselect2 shenfenselect4">
							        </select>
								</p>
								<p class="main">
									<span class="leftmain">详 细 地 址</span>
									<input type="text" id="information_address" value="${newClientUtil.information.information_address}" placeholder="&nbsp;&nbsp;请输入详细地址 " class="shurukuang">
								</p>
								<p class="main">
									<span class="leftmain">电 话&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
									<input type="text" id="information_phone" value="${newClientUtil.information.information_phone}" placeholder="&nbsp;&nbsp;请输入电话 " class="shurukuang">
								</p>
								<p class="main">
									<span class="leftmain">备 注&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
									<input type="text" id="information_remarks" value="${newClientUtil.information.information_remarks}" placeholder="&nbsp;&nbsp;请输入备注 " class="shurukuang">
								</p>
								<p class="main">
									<span class="leftmain">所 属 部 门</span>
									<select id="department_id" class="shenfenselect shenfenselect3">
							            <c:forEach items="${departments}" var="department">
							            	<option value="${department.department_id}">${department.department_name}</option>
							            </c:forEach>
							        </select>
								</p>
								<p class="main">
									<span class="leftmain">客 户 级 别</span>
									<select id="rankId" class="shenfenselect shenfenselect3">
							            <c:forEach items="${ranks}" var="rank">
							            	<option value="${rank.rankId}">${rank.rankName}</option>
							            </c:forEach>
							        </select>
								</p>
								<p class="main">
									<span class="leftmain">上 级 客 户</span>
									<input type="text" id="client_parent" value="${newClientUtil.client.client_parent}" class="shurukuang">
								</p>
								<p class="main">
									<span class="leftmain">行 业&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
									<select id="tradeManageId" class="shenfenselect shenfenselect3">
							            <c:forEach items="${tradeManages}" var="tradeManage">
							            	<option value="${tradeManage.tradeManageId}">${tradeManage.tradeName}</option>
							            </c:forEach>
							        </select>
								</p>
								<p class="main">
									<span class="leftmain">邮 政 编 码</span>
									<input type="text" id="information_postalcode" value="${newClientUtil.information.information_postalcode}" class="shurukuang">
								</p>
								<p class="main">
									<span class="leftmain">传 真&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
									<input type="text" id="information_fax" value="${newClientUtil.information.information_fax}" placeholder="&nbsp;&nbsp;请输入传真 " class="shurukuang">
								</p>
								<p class="main">
									<span class="leftmain">公 司 网 址</span>
									<input type="text" id="information_website" value="${newClientUtil.information.information_website}" placeholder="&nbsp;&nbsp;请输入公司网址 " class="shurukuang">
								</p>
								<p class="main">
									<span class="leftmain">微 博&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
									<input type="text" id="information_microblog" value="${newClientUtil.information.information_microblog}" placeholder="&nbsp;&nbsp;请输入微博 " class="shurukuang">
								</p>
								<p class="main">
									<span class="leftmain">总人数&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>
									<input type="text" id="client_headcount" value="${newClientUtil.client.client_headcount}" placeholder="&nbsp;&nbsp;请输入总人数 " class="shurukuang">
								</p>
								<p class="main">
									<span class="leftmain">销售额（元）</span>
									<input type="text" id="client_saleroom" value="${newClientUtil.client.client_saleroom}" placeholder="&nbsp;&nbsp;请输入销售额 " class="shurukuang shurukuang2">
								</p>
								<p class="main">
									<button class="btn1 btn2" onclick="saveContract()">保存</button>
									<button class="btn1 btn3">取消</button>
								</p>
			    		</div>
					 	</div>
					 	<div id="idsssssss">
			    			<p id="client_id">${newClientUtil.client.client_id}</p>
			    			<p id="informationID">${newClientUtil.client.informationID}</p>
			    			<p id="communalID">${newClientUtil.client.communalID}</p>
			    			<p id="department_ID">${newClientUtil.client.departmentID}</p>
			    			<p id="rank_id">${newClientUtil.client.rankID}</p>
			    			<p id="vocation_id">${newClientUtil.client.vocationID}</p>
			    		</div>

		
       <script
		src="${pageContext.request.contextPath}/salejihui/js/jquery-1.8.3.min.js"></script>
	<script
		src="${pageContext.request.contextPath}/salejihui/js/jquery.pagination.js"></script>
	<script
		src="${pageContext.request.contextPath}/salejihui/My97DatePicker/WdatePicker.js"></script>
	<script
		src="${pageContext.request.contextPath}/salejihui/js/jquery.validate.min.js"></script>
	<script
		src="${pageContext.request.contextPath}/salejihui/js/messages_zh.min.js"></script>
    </body>
<script>

			function del(id){
			
        	var clientId=$("#clientId").val();
			var url="${pageContext.request.contextPath}/SaleTrack/deleteclient.action";
					var pam={
							saletrackId:id,
							clientId:clientId
						};
					$.getJSON(url,pam,function(data){
						alert("删除成功");
						$(".qingkong").empty();
						$(".shijian").empty();
						$(".liuyan").empty();	
						$.each(data,function(i,zhuijia){
							
							var objDiv="<div class='shijian' style='width: 100%;height: 30px;line-height: 32px;color:#8fa1b2;padding: 0px 14px;'>"+zhuijia.Date+"</div><ul class='liuyan' style='padding-top: 0px;margin-top: 0px;padding-bottom: 10px;'><li class='liuyanp' style='background: none;margin-top: 0px;'><span class='smallpic' style='margin-top: 20px;'><img src='${pageContext.request.contextPath}/salejihui/images/icon (29).png' class='smallpic2'>"+zhuijia.staff+"<span style='color:#adadae;margin-left:15px'>"+zhuijia.record+"联系了"+zhuijia.client+"客户</span></span><span class='deleting' style='margin-top: 10px;float: right;margin-right: 10px;' onclick='del("+zhuijia.saleTrack.saletrackId+")'>删 除<br></span><br>"
	    		  			+"<span class='liutxt'>事件类型:"+zhuijia.record+"</span><br><span class='liutxt'>客户反馈:"+zhuijia.saleTrack.saletrackFeedback+"</span><br><span class='liutxt'>重要情况说明:"+zhuijia.saleTrack.saletrackStatusstatement+"</span><br><span class='liutxt'>情况跟踪描述:"+zhuijia.saleTrack.saletrackDescrip+"</span><br></li></ul>";
							$(".qingkong").append(objDiv);
						});
						
				}); 
			    }
		
		
	 
				
		       $(function(){
		       $("#salestrack").validate({  
					onsubmit:true,// 是否在提交是验证  
					onfocusout:false,// 是否在获取焦点时验证  
					onkeyup :false,// 是否在敲击键盘时验证  
					  
					rules: {  
						saletrackFeedback:{
                        required:true
                    	},
					},  
					messages:{  
						saletrackFeedback:{
                        required:"客户反馈不能为空"
                    	},  
					},  
					submitHandler: function(form) {  //通过之后回调  
					    var jilu=$("#onessss").find("option:selected").attr("value");
		 
		var url="${pageContext.request.contextPath}/SaleTrack/insertclient.action";
					var pam={
							saletrackFeedback:$("#fankui").val(),
							recordId:jilu,
							saletrackStatusstatement:$("#shuoming").val(),
							saletrackDescrip:$("#miaosu").val(),
							staffId:$("#staffId").val(),
							clientId:$("#clientId").val()
							};
					
					$.getJSON(url,pam,function(data){	
						if(data.length!=0){ 
						$(".qingkong").empty();
						$(".shijian").empty();
						$(".liuyan").empty();	
						$.each(data,function(i,zhuijia){
							
							var objDiv="<div class='shijian' style='width: 100%;height: 30px;line-height: 32px;color:#8fa1b2;padding: 0px 14px;'>"+zhuijia.Date+"</div><ul class='liuyan' style='padding-top: 0px;margin-top: 0px;padding-bottom: 10px;'><li class='liuyanp' style='background: none;margin-top: 0px;'><span class='smallpic' style='margin-top: 20px;'><img src='${pageContext.request.contextPath}/salejihui/images/icon (29).png' class='smallpic2'>"+zhuijia.staff+"<span style='color:#adadae;margin-left:15px'>"+zhuijia.record+"联系了"+zhuijia.client+"客户</span></span><span class='deleting' style='margin-top: 10px;float: right;margin-right: 10px;' onclick='del("+zhuijia.saleTrack.saletrackId+")'>删 除<br></span><br>"
	    		  			+"<span class='liutxt'>事件类型:"+zhuijia.record+"</span><br><span class='liutxt'>客户反馈:"+zhuijia.saleTrack.saletrackFeedback+"</span><br><span class='liutxt'>重要情况说明:"+zhuijia.saleTrack.saletrackStatusstatement+"</span><br><span class='liutxt'>情况跟踪描述:"+zhuijia.saleTrack.saletrackDescrip+"</span><br></li></ul>";
							$(".qingkong").append(objDiv);
						
						});
							//这个对象名自己起
							$("#fankui").val("");
							$("#shuoming").val("");
							$("#miaosu").val("")
						}
						});  
						    },  
						    invalidHandler: function(form, validator) {  //不通过回调  
						    	return false;  
						    }  
						});
		       
		       
			    	$(".opennew").click(function(e){
			        e.preventDefault();
			        $("#cover").css("display","block");
			        $("#cover").animate({
			            width: "100%",
			            height: "1800px",
			            top: "0",
			            left: "0"
			        },10);
			        /*$("#cover-content").animate({
			            width: "300px",
			            height: "300px",
			        },800);*/
			    });
			    $(".close").click(function(){
			        $("#cover").removeAttr("style");
			        $("#cover-content").removeAttr("style");
			    });
			    
			    
			    
			});
		       
		  </script> 
		 <script type="text/javascript">
		 
			 function saveContract(){
			    	var client_id = $("#client_id").html();
			    	if(client_id == ""){
			    		alert("发生未知错误为空");
			    		return;
			    	}
			    	var communalID = $("#communalID").html();
			    	var information_id = $("#informationID").html();
			    	var client_name = $("#client_name").val();
			    	var sheng = $("#sheng option:selected").val();
			    	var shi = $("#shi option:selected").val();
			    	var xiang = $("#xiang option:selected").val();
			    	var information_province = null;
			    	var information_city = null;
			    	var information_area = null;
			    	if(sheng != ""){
			    		information_province = sheng;
			    		information_city = shi;
				    	information_area = xiang;
			    	}
			    	var department_id = $("#department_id option:selected").val();
			    	var rankID = $("#rankId option:selected").val();
			    	var information_address = $("#information_address").val();
			    	var information_phone = $("#information_phone").val();
			    	var information_remarks = $("#information_remarks").val();
			    	var client_parent = $("#client_parent").val();
			    	var vocationID = $("#tradeManageId option:selected").val();
			    	var information_postalcode = $("#information_postalcode").val();
			    	var information_fax = $("#information_fax").val();
			    	var information_website = $("#information_website").val();
			    	var information_microblog = $("#information_microblog").val();
			    	var client_headcount = $("#client_headcount").val();
			    	var client_saleroom = $("#client_saleroom").val();
			    	var usdata = {information_province:information_province,client_id:client_id,communal_id:communalID,information_id:information_id,
			    			client_name:client_name,information_province:information_province,departmentID:department_id,
			    			rankID:rankID,information_address:information_address,information_phone:information_phone,information_remarks:information_remarks,
			    			client_parent:client_parent,vocationID:vocationID,information_postalcode:information_postalcode,
			    			information_fax:information_fax,information_website:information_website,information_microblog:information_microblog,
			    			client_headcount:client_headcount,client_saleroom:client_saleroom,information_city:information_city,information_area:information_area};
			    	$.ajax({
						type:"post",
						url:"<%=basePath %>client/update.action",
						data:usdata,
						success:function(data){
							alert(data);
							if(data == "修改成功"){
								location.href="<%=basePath %>client/findByClientId.action?id="+client_id;
							}
						},
						error:function(e){
							alert("发生未知错误请刷新页面");
							location.href="<%=basePath %>client/findByClientId.action?id="+client_id;
						}
			
			   		 });
			    }
			 	$("#idsssssss").hide();
			 	var department_ID = $("#department_ID").html();
			    var vocation_id = $("#vocation_id").html();
			    var rank_id = $("#rank_id").html();
			    $("#department_id").find("option[value='"+department_ID+"']").attr("selected",true);
			    $("#tradeManageId").find("option[value='"+vocation_id+"']").attr("selected",true);
			    $("#rankId").find("option[value='"+rank_id+"']").attr("selected",true);
		 
		 
		 
		 </script>
		 <script type="text/javascript" defer>
	    	new PCAS("province3","city3","area3");
	    </script>
</html>
